<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>修改密码处理页</title>
</head>
<body>
	<?php 
	require_once("./system/loginCheck.php");
	 ?>

	<?php
    require_once("../congfig/config.php");
    


	$oldpw=$_POST["oldpasswd"];
	$npw=$_POST["passwd"];
	$npw1=$_POST["veriypasswd"];
	

	//取数据库中的原密码
	$teacher=$_SESSION['username'];
	$sql="select passwd from users where username='$teacher'";
	$result=$conn->query($sql);
	$row=$result->fetch_array();

	if (strcmp(md5($oldpw), $row["passwd"])!=0) {
		header("location:pad-check.php?text=原密码输入错误!");
	}
    elseif (strcmp($npw, $npw1)) {
		header("location:pad-check.php?text=两次密码输入不同");
	}
	else{
		$sql1="update users set passwd=md5('$npw') where username='$teacher'";
		$result1=$conn->query($sql1);
		if ($result1==1) {
			$text="修改密码成功";
			header("location:pad-check.php?text=$text");
			
		}
		else{
			echo "失败";
		}

	}

		?>
</body>
</html>